<!DOCTYPE html>
<html lang="en">
<head>
	<meta charset="UTF-8">
	<title>JS组合式继承</title>
	<script type="text/javascript">
		function father(name){
			this.name =name;
			this.property=["black","green","yellow"];
		}
		//父类
		father.prototype.sayName = function(){
			alert(this.name);
		}
		function son(name,age){
			father.call(this,name);
			//用call改变父类构造函数的运行环境，借鉴了构造函数模式，使得更改不同的实例可能
			this.age = age;
		}
		son.prototype = new father();
		son.prototype.sayAge= function(){
			alert(this.age)
		}
		var aSon = new son('Mike',7);
		var anotherSon = new son('John',3);
		aSon.property.push("red");
		aSon.sayAge();
		aSon.sayName();
		alert(aSon.property);
		alert(anotherSon.property);








	</script>
</head>
<body>
</body>
</html>